import { post, get, put, del } from "./service"
import {ref,unref} from 'vue'
import axios from "axios"


const request = axios.create({
    // 指定请求的根路径
    baseURL: 'https://service-kq8d34ry-1322805030.gz.tencentapigw.com/release/'
  })
  const qs = require('qs')


//获取轮播图
export const getBannerApi = data => {
    return get({
        // url: 'banner',
        url: 'banner/type=2',
        data,
        timestamp: new Date().getTime()
    })
}

/*
手机登录
 /captcha/sent
 
*/
export const captchaApi = data => {
    return post({
        url: `captcha/sent?phone=${unref(data)}`,
        data,
        timestamp: new Date().getTime()
    })
}
/* 
验证验证码
captcha/verify
调用例子 : /captcha/verify?phone=13xxx&captcha=1597
*/
// 验证短信验证码
export const verifyApi = function (values) {
    return request.post('/captcha/verify', qs.stringify({
      phone: values.user,
      captcha: values.captcha,
      timestamp: new Date().getTime()
    }))
  }

/* 
手机登录
接口地址 : login/cellphone
调用例子 : login/cellphone?phone=xxx&password=yyy /login/cellphone?phone=xxx&md5_password=yyy /login/cellphone?phone=xxx&captcha=1234v
*/
export const loginApi = data => {
    return get({
        // url: 'banner',
        url: 'login/cellphone',
        phone:data.user,
        captcha: data.captcha,
        timestamp: new Date().getTime()
    })
}
/* 
获取推荐歌单(未登录)
可选参数 : limit: 取出数量 , 默认为 30 (不支持 offset)
接口地址 : /personalized
调用例子 : /personalized?limit=1
*/
export const getPlayListsApi = data => {
    return get({
        url: `personalized?limit=${data}`,
        limit:data,
        timestamp: new Date().getTime()
    })
}

